#include <iostream>

class Proxy;
//抽象的被代理对象
class AbstractSystem
{
public:
    virtual void run() = 0;
   
};

class Linux:public AbstractSystem
{
public:
    void run()
    {
        std::cout<<"Linux系统启动\n";
    }
};
class windows:public AbstractSystem
{
public:
    void run()
    {
        std::cout<<"window系统启动\n";
    }
};
class Proxy
{
public:
    Proxy(const std::string & user, const std::string& passwd)
    {
        this->user = user;
        this->passwd = passwd;
    }
    void run()
    {
        if(user == "admin" && passwd == "123456")
        {
            s = new windows;
            s->run();
        }
        else if(user == "root" && passwd == "1")
        {
            s = new Linux;
            s->run();
        }
        else
        {
            std::cout<<"登录系统失败\n";
        }
    }
private:
    std::string user;
    std::string passwd;
    AbstractSystem *s;//要代理的对象

};

int main()
{
    
    // Proxy p("admin", "123456");
    Proxy p("root", "1");
    p.run();
}